home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 90 / CD Actual 90.iso / Software3D / VirtualLight / VLight1.3win32.exe / VibSDK / Samples / sample5.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-07  |  2.1 KB  |  81 lines

  1. /*
  2.  * VirtuaLight's binary .VIB format API, sample 5
  3.  * Written by Stephane Marty, 09/10/2001
  4.  *
  5.  * Displacement mapping test on a sphere
  6.  * SAMPLE5.VS contains shader and displacement declarations.
  7.  */
  8.  
  9. #include "..\vlBinDef.h"
  10.  
  11. void main(void)
  12. {
  13.     viSPHERE    sphere;
  14.     viDISK        disk;
  15.     viCAMERA            *cam;
  16.     viGENERAL            *gen;
  17.     viSHAPE_MODIFIERS    *shpmod;
  18.     viPOINT_LIGHT        *pl;
  19.     viFILE                *vib;
  20.    
  21.     // Open a new VIB file
  22.     vib = viNewBinaryVIB("sample5.vib");
  23.  
  24.     // Add the camera (low adaptive antialiasing enabled)
  25.     cam = viNewCamera();
  26.     viSetInt(cam->Format.X, 256);
  27.     viSetInt(cam->Format.Y, 256);
  28.     viSetDbl(cam->FrameAspectRatio, 1.0);
  29.     viSetVector(&cam->Location, 0, 3, -6);
  30.     viSetVector(&cam->LookAt, 0, 1.5, 0);
  31.     viSetVector(&cam->UpAxis, 0, 1, 0);
  32.     viSetDbl(cam->FieldOfView, 40);
  33.     viSetInt(cam->Antialiasing, 1);
  34.     viDumpCamera(cam, vib);
  35.  
  36.     // Set the background color
  37.     gen = viNewGeneral();
  38.     viSetColor(&gen->Background, 0.098039*2, 0.098039*2, 0.392157*2);
  39.     viDumpGeneral(gen, vib);
  40.  
  41.     // Add two pointlights
  42.     pl = viNewPointLight();
  43.     viSetColor(&pl->Intensity, 0.6, 0.6, 0.6);
  44.     viSetVector(&pl->Position, 10, 30, -25);
  45.     viDumpPointLight(pl, vib);
  46.     viSetColor(&pl->Intensity, 0.7, 0.7, 0.7);
  47.     viSetVector(&pl->Position, -15, 20, -20);
  48.     viDumpPointLight(pl, vib);
  49.  
  50.     // A simple disk for the floor
  51.     viPrimitive(vib);
  52.     viSetVector(&disk.center, 0, 0, 0);
  53.     viSetVector(&disk.normal, 0, 1, 0);
  54.     viSetDbl(disk.radius, 200);
  55.     viDumpDisk(&disk, vib);
  56.     viPrimitiveShaderName("veins_pattern", vib);
  57.     viEndPrimitive(vib);
  58.  
  59.     // The sphere with its shader...
  60.     viPrimitive(vib);
  61.     viSetVector(&sphere.center, 0, 1.5, 0);
  62.     viSetDbl(sphere.radius, 1.5);
  63.     viDumpSphere(&sphere, vib);
  64.     viPrimitiveShaderName("ball", vib);
  65.     // ...and its shape modifiers
  66.     shpmod = viNewShapeModifiers();
  67.     viSetInt(shpmod->ShapeSubdivisions.u, 128);
  68.     viSetInt(shpmod->ShapeSubdivisions.v, 128);
  69.     viSetString(shpmod->DisplacementMapping, "Emboss");
  70.     viDumpShapeModifiers(shpmod, vib);
  71.     viEndPrimitive(vib);
  72.  
  73.     // Close the VIB file
  74.     viCloseBinaryVIB(vib);
  75.  
  76.     // Deallocate memory used
  77.     free(cam);
  78.     free(gen);
  79.     free(pl);
  80.     free(shpmod);
  81. }